package chat;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * @Author 刘牌
 * @Date 2020/3/16 0016 16:24
 * @Version 1.0
 */

public class NettyClientHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ByteBuf byteBuf = (ByteBuf) msg;
        int len = byteBuf.readableBytes();
        byte[] bytes = new byte[len];
        byteBuf.getBytes(0,bytes);
        System.out.println("收到服务器发来的信息为： "+new String(bytes,"UTF-8"));
        byteBuf.release();
    }
}
